package com.kot32.dynamicloadviewlibrary.util;


import ohos.agp.utils.Color;
import ohos.app.Context;

public class DisplayUtil {

    private DisplayUtil() {
    }

    public static int px2vp(Context context, float pxValue) {
        final float scale = context.getResourceManager().getDeviceCapability().screenDensity/160;
        return (int) (pxValue / scale + 0.5f);
    }

    public static int vp2px(Context context, float dipValue) {
        final float scale = context.getResourceManager().getDeviceCapability().screenDensity/160;
        LogUtil.i("scale: %f", scale);
        return (int) (dipValue * scale + 0.5f);
    }




    public static int makePressColor(int color, int alpha) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = (color >> 0) & 0xFF;
        r = (r - 30 < 0) ? 0 : r - 30;
        g = (g - 30 < 0) ? 0 : g - 30;
        b = (b - 30 < 0) ? 0 : b - 30;
        return Color.argb(alpha, r, g, b);
    }


}
